if (files.cwd().endsWith("脚本")) {
    let _require = require;
    require = function (path) {
           if (path.startsWith("./")) {
                  path = path.replace("./", "");
           }
           path = files.cwd() + "/gdt_hb/" + path;
           return _require(path);
    }
}

var utils = require("./utils.js");
auto.waitFor()
var storage = storages.create("xiangxiangyuedu");
var time = random(2000, 3000)

function main(){
    var open = utils.launchAppEnhance("BENCOIN");
    if(open){
        console.log("等待进入首页")
        waitForActivity("io.dcloud.PandoraEntryActivity")
        console.log("进入到首页完毕");
        
        sleep(5000)
        var 矿机 = text("矿机").findOne(60000);
        if(矿机){
            utils.realClick(矿机);
            sleep(2000);
            var 签到 = text("签到").findOne(60000);
            utils.realClick(签到);
            sleep(5000);
            if(text("签到规则").findOne(200)){
                签到 = className("android.widget.Image").depth(15).indexInParent(1).findOne(200)
                if(签到){
                    utils.realClick(签到);
                }
            }
        }
    }
}

try {
    main();
    utils.updateAppProgress(100);
} catch (error) {
    toastLog(error);
}
storage.put("script_running_status", "end");